Skip to content

Conversation

@RobertOdrowaz
Copy link
Contributor

Migrates camera wrappers as part of flutter/flutter#119109

This PR migrates wrappers to Swift:

  • FLTCaptureConnection
  • FLTCaptureDeviceFormat
  • FLTAssetWriter

In line with Swift conventions, the FLT prefixes are removed. The Default class implementations are replaced with protocol conformance on base AV classes.

Pre-Review Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. 2 3

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request continues the migration of Objective-C code to Swift by converting FLTCaptureConnection, FLTCaptureDeviceFormat, and FLTAssetWriter from wrapper classes to Swift protocols. This is a solid architectural improvement that makes the code more idiomatic and type-safe. The changes are consistently applied throughout the codebase, including tests and mocks. I have one minor suggestion to further align the code with Swift conventions.

@stuartmorgan-g stuartmorgan-g added the triage-ios Should be looked at in iOS triage label Nov 18, 2025
@RobertOdrowaz RobertOdrowaz force-pushed the feature/camera-wrappers-swift-migration-part4 branch from c962452 to 7948414 Compare November 20, 2025 15:26
@RobertOdrowaz
Copy link
Contributor Author

@hellohuanlin pls take a look at this PR again when you have some time

Copy link
Contributor

@hellohuanlin hellohuanlin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay. Overall looks good.

/// A mock implementation of `FrameRateRange` that allows mocking the class properties.
final class MockFrameRateRange: NSObject, FrameRateRange {
var minFrameRate: Float64
var maxFrameRate: Float64
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this change required?

return FLTDefaultCaptureConnection(connection: connection)
func connection(with mediaType: AVMediaType) -> CaptureConnection? {
let connection: AVCaptureConnection? = connection(with: mediaType)
return connection
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can be 1 line

return FLTDefaultCaptureConnection(connection: connection)
func connection(with mediaType: AVMediaType) -> CaptureConnection? {
let connection: AVCaptureConnection? = connection(with: mediaType)
return connection
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can be 1 line

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you need infer the type, you can do return AVCaptureConnection.connection(with: mediaType)

// https://github.com/flutter/flutter/issues/132016
// https://github.com/flutter/flutter/issues/151319
videoWriter?.startWriting()
// Result ignored in line with the Objective-C implementation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you also comment what the result is? also this comment is confusing because there wont' be any objc implementation after the migration

videoAdaptor?.append(nextBuffer!, withPresentationTime: nextSampleTime)
if videoWriterInput?.isReadyForMoreMediaData ?? false {
// Result ignored in line with the Objective-C implementation
let _ = videoAdaptor?.append(nextBuffer!, withPresentationTime: nextSampleTime)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants